<%--
  Created by IntelliJ IDEA.
  User: zhuo_pc
  Date: 2022/7/7
  Time: 10:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String CONTEXT_PATH = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    out.clear();
%><?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
    <title>查询列表</title>
    <base href="<%=CONTEXT_PATH%>">
    <jsp:include page="/resources/v2/webui.jsp">
        <jsp:param name="UIS" value="FORM_DGRID_LAYER_BTN_LAYOUT_PAGE_ZTREE"/>
    </jsp:include>

</head>
<body>
<div class="tdh_layout" style="padding-top: 65px">
    <div class="tdh_layout_t" style="height: 65px">
        <div class="tdh_form_search">
            <table>
                <colgroup>
                    <col width="100"/>
                    <col width="150"/>
                    <col width="*"/>
                </colgroup>
                <tr>
                    <td class="tdTitle">姓名/账号：</td>
                    <td class="tdCont">
                        <input class="inputText" type="text" placeholder="支持模糊查询" type='text' id= "userName" name='username'/>
                    </td>

                    <td align="right">
                        <a class="tdh_btn tdh_btn_blue" value="查询" onclick="searchUser()"><i class="tdh_icon icon_search"></i>查询</a>
                        <a class="tdh_btn tdh_btn_blue" onclick="addForm()" id = "add"><i class="tdh_icon icon_add"></i>新增</a>
                        <a class="tdh_btn tdh_btn_yellow" href="/user/logout">注销</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="tdh_layout_c">
        <div class="tdh_layout">
            <div class="tdh_layout_l depart" style="width: 240px; border: 1px solid #dcdcdc">
                <ul class="ztree" id="treeDiv" style="height: 100%;width:100%;overflow-y: auto;"></ul>
            </div>
            <div class="tdh_layout_r " style="margin-left: 245px">
                <div id="grid" class="list" style="width:100%; height: 100%;">
                    <table></table>
                </div>
            </div>
        </div>
    </div>
</div>

</body>

<script>
    var zTree;
    var mygrid;
    $(function () {
        initZtree();
        initGrid();
    })
    var setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            onDblClick: nodeDbClick,
            onAsyncSuccess: function () {
            },
            onExpand: function () {
            }

        }
    };

    //用户详情窗口
    //yhid 用户id
    function viewUser(yhid) {

        var open = layer.open({
            type: 2,
            title: '查看信息',
            area: ['700px','450px'],
            shadeClose: false,      //点击遮罩不关闭层
            content: CONTEXT_PATH + "user/userDetail?YHID="+yhid+"&type=0"
        });

    }
    //用户修改窗口
    //yhid 用户id
    function editUser(yhid) {
        layer.open({
            type: 2,
            title: '修改信息',
            area: ['700px','450px'],
            shadeClose: false,      //点击遮罩不关闭层
            content: CONTEXT_PATH + "user/userDetail?YHID="+yhid+"&update=1"
        })
    }
     // 删除当前行
     // @param YHID 当前节点对应行的用户id
    function deleteUser (yhid) {
            $.ajax({
                url: CONTEXT_PATH+'user/userDelete?YHID='+yhid,
                type: 'get',
            });
                mygrid.loadXML(CONTEXT_PATH+"user/userList");

    }

    var ztreeData = [
        {id: 1, pId: 0, name: "南京通达海", open: true, iconSkin: "courtIcon"},

        {id: 2, pId: 1, name: "立案庭", iconSkin: "crowdIcon"},
        {id: 3, pId: 1, name: "业务庭", iconSkin: "crowdIcon"},
        {id: 2, pId: 1, name: "办公室", iconSkin: "crowdIcon"}
    ];

    function initZtree() {
        zTree = $.fn.zTree.init($("#treeDiv"), setting, ztreeData);
    }

    // ztree 双击事件
    function nodeDbClick(event, treeId, treeNode, clickFlag) {
    }
    function initGrid() {
        mygrid = new dhtmlXGridObject('grid');
        mygrid.setImagePath(CONTEXT_PATH + "/resources/v2/static/plugg/dhtmlx/dhtmlxGrid/codebase/imgs/");
        mygrid.setHeader("#master_checkbox,序号,查看,修改,删除,姓名,部门小组,登记日期,性别");
        mygrid.setInitWidths("80,100,80,80,80,200,*,200,200");//设置列宽  *表示自适应
        mygrid.setColTypes("ch,ro,img,img,img,ro,ro,ro,ro");//设置列类型
        mygrid.setColSorting("na,int,na,na,str,str,str,str");//设置列排序依据
        mygrid.setColAlign("center,center,center,center,center,center,center,center,center");//设置列显示位置
        mygrid.setSkin("tdh_default");//设置皮肤
        mygrid.pagingLayout("first,prev,page,next,last,limit,refresh,skip,count");//设置分页排版
        mygrid.pagingLimits("10,20,50");//设置每页条数的选择项
        mygrid.enablePagingon(true, 10);//true显示分页、10为默认每页条数
        // mygrid.setPageCurrent(2);//设置当前页
        mygrid.init();//初始化
        mygrid.loadXML(CONTEXT_PATH+"user/userList");//请求后台数据 并将数据构造成表格
        searchUser();
    }
    /*
    *搜索
    * 参数用户姓名
    *
    * */
    function searchUser() {
        //user为null，赋值为空字符串
        mygrid.loadXML(CONTEXT_PATH+"user/userList?username="+document.getElementById("userName").value);//请求后台数据 并将数据构造成表格
    }

    // 新增
    function addForm() {
        var open = layer.open({
            type: 2,
            title: "新增",
            area: ['700px', '500px'],
            shadeClose: true, //点击遮罩关闭
            content: CONTEXT_PATH + "user/toDetail"
        });

       layer.close(1);
    }


</script>
</html>
